package com.atguigu.flink.function;

import com.atguigu.flink.pojo.WordCount;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.util.Collector;

/**
 * Created by Smexy on 2023/4/1
 */
public class MyWordCountFlatMapFunction implements FlatMapFunction<String, WordCount>
{
    @Override
    public void flatMap(String line, Collector<WordCount> out) throws Exception {
        String[] words = line.split(" ");
        for (String word : words) {
            out.collect(new WordCount(word, 1));
        }
    }
}
